package cn.itcast.nems.base.util;

import cn.itcast.nems.base.dao.entity.E2Clazz;
import cn.itcast.nems.base.dto.ClazzDTO;
import cn.itcast.nems.common.constant.TeachingModelEnum;
import org.springframework.beans.BeanUtils;
import org.springframework.lang.NonNull;

/**
 * 班级工具类
 *
 * @author ChangLu.Gao
 * @version v1.0
 * @program nems-server
 * @description
 * @date 2023/11/14 16:21
 */
public class ClazzUtil {

    /**
     * 将E2Clazz转换为ClazzDTO进行传输
     *
     * @param source 源数据
     * @return 用于传输类的对象
     */
    public static ClazzDTO convert(@NonNull E2Clazz source) {
        ClazzDTO target = new ClazzDTO();
        BeanUtils.copyProperties(source, target);
        target.setClassId(source.getClazzId())
                .setClassName(source.getClazzName())
                .setModelId(source.getTeachingModel())
                .setModelName(TeachingModelEnum.valueOf(source.getTeachingModel()).getName())
                .setSchoolId(source.getSchoolCode())
                .setClassTypeId(source.getClazzTypeId())
                .setClassTypeName(source.getClazzTypeName())
                .setStartDate(source.getStartDate())
                .setGraduationTime(source.getGraduationDate())
                .setStudentNumber(source.getStudentNumber())
                .setDelayFlag(source.getDelayFlag())
                .setSuspensionFlag(source.getSuspensionFlag());
        return target;
    }
}
